<template>
	<view class="reply-container">
		<view style="padding: 20rpx;">
			<view class="toast-top">
				<view class="flex">
					<text style="color: red;">*</text>
					<view class="desc">通知标题</view>
				</view>
			</view>
			<view class="c-input">
				<input type="text" v-model="params['标题']" placeholder="请输入通知标题">
			</view>
			<view class="toast-top">
				<view class="flex">
					<text style="color: red;">*</text>
					<view class="desc">通知内容</view>
				</view>
			</view>
			<!-- <view class="title"><text style="color: red;">*</text>评价描述</view> -->
			<textarea style="height: 400rpx;" v-model="params['内容']" class="content" placeholder="请输入通知内容..." name="" id="" cols="30" rows="10"></textarea>
			<view class="toast-top">
				<view class="flex">
					<text style="color: #fff;">*</text>
					<view class="desc">附件图片(最多三张)</view>
				</view>
			</view>
			<uploader :bmargin="6" v-model="params['附件']"></uploader>
		</view>
		<button class="grid-btn" @click="submit">提交</button>
	</view>
</template>

<script>
	import LbPicker from '../components/lb-picker'
	import uploader from '../components/upload.vue'
	export default {
		components: {
			LbPicker,
			uploader
		},
		data() {
			return {
				params: {
					通知的网格: null,
					标题: '',
					内容: '',
					附件: []
				}
			}
		},
		onLoad(options) {
			
		},
		methods: {
			// onChange(e) {
			// 	console.log('rate发生改变:' + JSON.stringify(e))
			// 	console.log(this.rateValue)
			// },
			submit() {
				if(this.params.标题.trim() == '') {
					uni.showToast({
						title: '请输入通知标题',
						icon: 'none'
					})
				}else if(this.params.内容.trim() == '') {
					uni.showToast({
						title: '请输入通知内容',
						icon: 'none'
					})
				}else {
					this.addNotice()
				}
			},
			addNotice() {
				uni.showLoading({
					mask: true
				})
				this.params.通知的网格 = [uni.getStorageSync('gridInfo').所属网格id]
				this.$http.post('gridSystem/message/add', this.params).then(res => {
					console.log(res)
					if (res.code === 10000) {
						uni.switchTab({
							url: '/pages/message/message'
						})
						// uni.redirectTo({
						// 	url: '/fireGridCheck/acceptSuccess/acceptSuccess?title=发布成功'
						// })
						// uni.redirectTo({
						// 	url: '/ticketSystem/acceptSuccess/acceptSuccess?path=../index/index' + '&title=返回工单首页'
						// })
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.color {
		color: #808080;
	}
	.reply-container {
		height: 100vh;
		// padding-bottom: 100rpx;
		// padding: 20rpx;
		.flex {
			display: flex;
			align-items: center;
		}

		.title {
			margin-bottom: 30rpx;
		}
		.c-input {
			padding-left: 20rpx;
			border: 2rpx solid #ccc;
			height: 70rpx;
			display: flex;
			align-items: center;
		}
		.content {
			width: 710rpx;
			padding: 20rpx;
			border: 2rpx solid #ccc;
		}

		.btn {
			width: 568rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin-top: 80rpx;
			background-color: #3080FB;
			color: #fff;
		}

		.toast-top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;
			margin-top: 20rpx;
			.desc {
				margin-right: 20rpx;
				font-size: 32rpx;
			}

			.desc-text {
				color: #BCBCBC;
				font-size: 30rpx;
				margin-left: 18rpx;
			}
		}
	}
</style>
